﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            FileStream stream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "PoolDeletingDomainsList.txt", FileMode.Open, FileAccess.Read);
            byte[] b = new byte[stream.Length];
            stream.Read(b, 0, (int)stream.Length);
            string result = Encoding.UTF8.GetString(b);
            Regex regDomain = new Regex("^[A-Za-z]+$");
            string[] domains = Regex.Split(result, "\r\n");
            SortedSet<string> set = new SortedSet<string>();
            for (int i = 0; i < domains.Length; i++)
            {
                if (string.IsNullOrEmpty(domains[i])) continue;
                var domain = domains[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0].Split('.');
                string name = domain[0];
                string domaintype = domain[1];
                if (domaintype.Equals("com", StringComparison.OrdinalIgnoreCase)
                    && regDomain.Match(name).Success &&
                    name.Length < 7)
                    set.Add(name);
            }
            Console.WriteLine("请输入要包含的字符");

            string code = Console.ReadLine();
            set.RemoveWhere(t => { return !t.Contains(code); });
            for (int i = 0; i < set.Count; i++)
            {
                Console.WriteLine(set.ElementAt(i));
            }
            Console.ReadLine();

        }
    }
}
